<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>计算</title>
</head>
<body>
<script>
  var num1 = parseFloat(prompt("请输入第一个数："));
  var num2 = parseFloat(prompt("请输入第二个数："));
  var op = prompt("请输入运算符：");
  switch (op) {
    case "+":
      console.log(num1 + num2);
      break
    case "-":
      console.log(num1 - num2);
      break;
    case "*":
      console.log(num1 * num2);
      break;
    case "/":
        if (num2 == 0){
            console.log("除数不能为0！")
        } else {
            console.log(num1 / num2);
        }
        break;
      default:
          console.log("输入的运算符无效！");
  }
</script>
</body>
</html>